﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ChoViet.Cms.ViewModels.MenuViewIndexModel>" %>
<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Lib.Paging" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Quản lý menu
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
	Quản lý menu
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
	<td>
	<%= Html.Toolbar("Thêm mới", "/Menu/Create", "new") %>
    </td>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <%if(ViewData["MessageInfo"]==null){ %>
	<form action="/Menu" method="post" name="adminForm">
		<table width="100%">
			<tr>
			    <td align="left">
			        Tìm nhanh <%= Html.TextBox("Keyword", Model.FilterName) %>
			        <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
			    </td>
				<td align="right">
				    <%=Html.DropDownList("ddlMenuType", new SelectList(Model.MenuTypes, "ID", "Name", Model.CurrentMenuType).ToList(), "-- Loại menu --", new { onchange = "document.adminForm.submit();" })%>
			    </td>
			</tr>
		</table>
		<table width="100%" class="adminlist">
		    <thead>
			<tr>
				<th width="10" align="right">
					STT
				</th>
				<th width="30"></th>
				<th width="30"></th>
				<th>
					<%= Html.Sort("Tiêu đề", "Name", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th width="120">
				    Link liên kết
				</th>
				<th width="80"> 
					<%= Html.Sort("Độ ưu tiên", "Priority", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th>
					Loại menu
				</th>
				<th style="width: 120px">
					<%= Html.Sort("Cập nhật", "AddDate", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
			</tr>
			</thead>
			<tbody>
		<% 
			int i = 0;
    		foreach (var item in Model.Menus) {
				i++;
		%>		
			<tr>
				<td align="right">
					<%= i.ToString() %>
				</td>
				<td align="center">
					<%= Html.ActionImage("Sửa", "icon-24-edit.png", "Menu", "Edit", new Dictionary<string, object>(){{ "id", item.ID }})%>
				</td>
				 <td align="center">
					<%= Html.ActionImage("Xóa", "icon-24-delete.png", "Menu", "Delete", new Dictionary<string, object>() { { "id", item.ID } })%>
				</td>
				<td>				    
				    <%= Html.Encode(item.Name)%>
				</td>
				<td><%=Html.Encode(item.NavigateUrl) %></td>
				<td>				    
				    <%=item.Priority%>
				</td>
				<td>				    
				    <%=Html.Encode(item.MenuType.Name) %>
				</td>
				<td>
					<%=String.Format("{0:g}", item.ModifyDate) %>
				</td>
			</tr>
	    
		<% } %>
        </tbody>
		</table>
		<%= Html.Hidden("order")%>
		<%= Html.Hidden("orderDir")%>
    <table width="100%">
        <tr>
            <td align="center">
                <div class="pager">
                    <label>
                        Hiển thị #</label>
                    <%
                        int[] pageSizeList = { 1, 5, 10, 15, 20, 25, 50, 100 };
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Menus.PageSize), new { onchange = "document.adminForm.submit();" })%>
                    <%= Html.Pager(Model.Menus.PageSize, Model.Menus.PageNumber, Model.Menus.TotalItemCount)%>
                </div>
            </td>
        </tr>
    </table>
	</form>
 <% } %>

</asp:Content>